package ar.edu.unrn.lia.util;

import java.io.Serializable;

import javax.inject.Inject;
import javax.inject.Named;

import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.scheduling.annotation.Async;

@Named("mailBusness")
public class MailBusness implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1122271929682902628L;
	@Inject
	private MailSender mailSender;

	public void setMailSender(MailSender mailSender) {
		this.mailSender = mailSender;
	}

	public MailSender getMailSender() {
		return mailSender;
	}
	

	public void sendMail(String from, String to, String subject, String msg) {

		try {

			SimpleMailMessage message = new SimpleMailMessage();

			message.setFrom(from);
			message.setTo(to);
			message.setSubject(subject);
			message.setText(msg);
			mailSender.send(message);
		} catch (Exception e) {

		}
	}
	
	
	public void sendMail(SimpleMailMessage[] emails)
	{
		
		try {
				mailSender.send(emails);
		} catch (Exception e) {

		}
	}

}
